home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / snmp / mib2c-data / node-set.m2i < prev    next >
Encoding:
Text File  |  2007-02-07  |  7.4 KB  |  230 lines

  1. #############################################################  -*- c -*-
  2. ## generic include for XXX. Do not use directly.
  3. ##
  4. ## $Id: node-set.m2i,v 1.20 2004/10/15 00:45:05 rstory Exp $
  5. ########################################################################
  6. @if $m2c_mark_boundary == 1@
  7. /** START code generated by $RCSfile: node-set.m2i,v $ $Revision: 1.20 $ */
  8. @end@
  9. ########################################################################
  10. ##
  11. ##----------------------------------------------------------------------
  12. /**
  13.  * Check that the proposed new value is potentially valid.
  14.  *
  15.  * @param rowreq_ctx
  16.  *        Pointer to the row request context.
  17.  * @param $m2c_node_param_val_name
  18.  *        A $node.decl containing the new value.
  19. @    if $m2c_node_needlength == 1@
  20.  * @param $m2c_node_param_val_lname
  21.  *        The size (in bytes) of the data pointed to by $m2c_node_param_val_name
  22. @    end@
  23.  *
  24.  * @retval MFD_SUCCESS        : incoming value is legal
  25.  * @retval MFD_NOT_VALID_NOW  : incoming value is not valid now
  26.  * @retval MFD_NOT_VALID_EVER : incoming value is never valid
  27.  *
  28.  * This is the place to check for requirements that are not
  29.  * expressed in the mib syntax (for example, a requirement that
  30.  * is detailed in the description for an object).
  31.  *
  32.  * You should check that the requested change between the undo value and the
  33.  * new value is legal (ie, the transistion from one value to another
  34.  * is legal).
  35.  *      
  36.  *@note
  37.  * This check is only to determine if the new value
  38.  * is \b potentially valid. This is the first check of many, and
  39.  * is one of the simplest ones.
  40.  * 
  41.  *@note
  42.  * this is not the place to do any checks for values
  43.  * which depend on some other value in the mib. Those
  44.  * types of checks should be done in the
  45.  * ${context}_check_dependencies() function.
  46.  *
  47.  * The following checks have already been done for you:
  48.  *    The syntax is $node.type
  49. @if $node.enums == 1@
  50.  *    The value is one of $m2c_evals
  51. @elsif $node.ranges == 1@
  52. @    if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@
  53. @        eval $m2c_tmp_ns = "value"@
  54. @    else@
  55. @        eval $m2c_tmp_ns = "length"@
  56. @    end@
  57.  *    The $m2c_tmp_ns is in (one of) the range set(s): $m2c_evals
  58. @end@
  59.  *
  60.  * If there a no other checks you need to do, simply return MFD_SUCCESS.
  61.  *
  62. @  if $mfd_code_verbose == 1@
  63. @    if ("$node.decl" eq "long") || ("$node.decl" eq "u_long")@
  64.  * For example, an object with the syntax INTEGER(0..500) will
  65.  * have already been checked for a value between 0 and 500. But
  66.  * if the description also specifies that the value must be an
  67.  * even number, you would enforce that requirement here. If and odd
  68.  * numer is set, return MFD_NOT_VALID_EVER. If the description also
  69.  * specified that changed must be made in single steps of 2, then a set
  70.  * to change the value 10 to an even value other than 8 or 12 should
  71.  * return MFD_NOT_VALID_NOW.
  72. @    else@
  73.  * For example, and object with the syntax DisplayString(0..40)
  74.  * will have already been checked for a length between 0 and 40.
  75.  * But if the description also specified that the value must
  76.  * be all uppercase letters, you would enforce that requirement here
  77.  * by returning MFD_NOT_VALID_EVER for a set containing lowercase
  78.  * letters. If the description also specified that the value can not
  79.  * change by more than one letter at a time, an attempt to change
  80.  * "ABBY" to "ANNIE" should return MFD_NOT_VALID_NOW.
  81. @    end@
  82.  *
  83. @  end@
  84.  */
  85. int
  86. ${node}_check_value( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_val)
  87. {
  88.     DEBUGMSGTL(("verbose:${context}:${node}_check_value","called\n"));
  89.  
  90.     /** should never get a NULL pointer */
  91.     netsnmp_assert(NULL != rowreq_ctx);
  92. @if $m2c_node_needlength == 1@
  93.     netsnmp_assert(NULL != $m2c_node_param_val_name);
  94. @end@
  95.  
  96.     /*
  97.      * TODO:441:o: |-> Check for valid $node value.
  98.      */
  99.  
  100.     return MFD_SUCCESS; /* $node value not illegal */
  101. } /* ${node}_check_value */
  102.  
  103. ##----------------------------------------------------------------------
  104. /**
  105.  * Save old value information
  106.  *
  107.  * @param rowreq_ctx
  108.  *        Pointer to the table context (${context}_rowreq_ctx)
  109.  *
  110.  * @retval MFD_SUCCESS : success
  111.  * @retval MFD_ERROR   : error. set will fail.
  112.  *
  113.  * This function will be called after the table level undo setup function
  114.  * ${context}_undo_setup has been called.
  115.  *
  116.  *@note
  117.  * this function will only be called if a new value is set for this column.
  118.  *
  119.  * If there is any setup specific to a particular column (e.g. allocating
  120.  * memory for a string), you should do that setup in this function, so it
  121.  * won't be done unless it is necessary.
  122.  */
  123. int
  124. ${node}_undo_setup( ${context}_rowreq_ctx *rowreq_ctx)
  125. {
  126.     DEBUGMSGTL(("verbose:${context}:${node}_undo_setup","called\n"));
  127.  
  128. @ifconf syntax-$node.syntax-undo-setup.m2i@
  129. @    include syntax-$node.syntax-undo-setup.m2i@
  130. @else@
  131.     /** should never get a NULL pointer */
  132.     netsnmp_assert(NULL != rowreq_ctx);
  133.  
  134.     /*
  135.      * TODO:455:o: |-> Setup $node undo.
  136.      */
  137. @   eval $m2c_ctx_lh = "${m2c_undo_item}${node}"@
  138. @   eval $m2c_ctx_lhs = "${m2c_undo_item}${node}_len"@
  139. @   eval $m2c_ctx_rh = "${m2c_data_item}${node}"@
  140. @   eval $m2c_ctx_rhs = "${m2c_data_item}${node}_len"@
  141. @   include generic-ctx-copy.m2i@
  142. @end@
  143.  
  144.     return MFD_SUCCESS;
  145. } /* ${node}_undo_setup */
  146.  
  147. ##----------------------------------------------------------------------
  148. /**
  149.  * Set the new value.
  150.  *
  151. @if $m2c_node_set_comments ne ""@
  152. $m2c_node_set_comments
  153. *
  154. @end@
  155.  * @param rowreq_ctx
  156.  *        Pointer to the users context. You should know how to
  157.  *        manipulate the value from this object.
  158.  * @param $m2c_node_param_val_name
  159.  *        A $node.decl containing the new value.
  160. @    if $m2c_node_needlength == 1@
  161.  * @param $m2c_node_param_val_lname
  162.  *        The size (in bytes) of the data pointed to by $m2c_node_param_val_name
  163. @    end@
  164.  */
  165. int
  166. ${node}_set( ${context}_rowreq_ctx *rowreq_ctx, $m2c_node_param_val )
  167. {
  168. @ifconf syntax-$node.syntax-set.m2i@
  169. @    include syntax-$node.syntax-set.m2i@
  170. @else@
  171.  
  172.     DEBUGMSGTL(("verbose:${context}:${node}_set","called\n"));
  173.  
  174.     /** should never get a NULL pointer */
  175.     netsnmp_assert(NULL != rowreq_ctx);
  176. @if $m2c_node_needlength == 1@
  177.     netsnmp_assert(NULL != $m2c_node_param_val_name);
  178. @end@
  179.  
  180. @    if $m2c_node_skip_mapping != 1@
  181. @        include generic-value-map-reverse.m2i@
  182. @    end@
  183. @    if ($node.enums != 1) || ("$node.perltype" ne "BITS")@
  184. @        include generic-ctx-set.m2i@
  185. @    end@ # ! enums & bits
  186. @end@ # no syntax include
  187.     return MFD_SUCCESS;
  188. } /* ${node}_set */
  189.  
  190. ##----------------------------------------------------------------------
  191. /**
  192.  * undo the previous set.
  193.  *
  194. @if $m2c_node_undo_comments ne ""@
  195. $m2c_node_undo_comments
  196. *
  197. @end@
  198.  * @param rowreq_ctx
  199.  *        Pointer to the users context.
  200.  */
  201. int
  202. ${node}_undo( ${context}_rowreq_ctx *rowreq_ctx)
  203. {
  204. @ifconf syntax-$node.syntax-undo.m2i@
  205. @    include syntax-$node.syntax-undo.m2i@
  206. @else@
  207.  
  208.     DEBUGMSGTL(("verbose:${context}:${node}_undo","called\n"));
  209.  
  210.     netsnmp_assert(NULL != rowreq_ctx);
  211.  
  212.     /*
  213.      * TODO:456:o: |-> Clean up $node undo.
  214.      */
  215. @   eval $m2c_ctx_rh = "${m2c_undo_item}${node}"@
  216. @   eval $m2c_ctx_rhs = "${m2c_undo_item}${node}_len"@
  217. @   eval $m2c_ctx_lh = "${m2c_data_item}${node}"@
  218. @   eval $m2c_ctx_lhs = "${m2c_data_item}${node}_len"@
  219. @   include generic-ctx-copy.m2i@
  220. @end@ # no syntax include
  221.     
  222.     return MFD_SUCCESS;
  223. } /* ${node}_undo */
  224.  
  225. ##
  226. ########################################################################
  227. @if $m2c_mark_boundary == 1@
  228. /** END code generated by $RCSfile: node-set.m2i,v $ $Revision: 1.20 $ */
  229. @end@
  230.